package opreation.impl;

import book.Book;
import book.BookList;
import opreation.IOperation;

//增加书籍
public class AddOperation implements IOperation {

    @Override
    public void work(BookList bookList) {
        System.out.print("想要添加的书名为：");
        String name = scanner.next();
        if(bookList.contains(name)){
            System.out.println("此书已存在，请勿重复添加！");
            return;
        }
        System.out.print("请输入作者：");
        String author = scanner.next();
        System.out.print("请输入价格：");
        double price = scanner.nextDouble();
        System.out.print("请输入类型：");
        String type = scanner.next();
        //调用书架类的添加函数
        bookList.add(new Book(name,author,price,type));
        System.out.println("添加成功！");
    }
}
